import { Component } from '@angular/core';
import { userRechargeService } from '../../service/userRecharge.service';
import { isBindPNService } from '../../service/isBindPN.service';

declare let $:any;

@Component({
    selector: 'press_center',
    templateUrl: '../../../views/user_recharge/userRecharge.html',
    styleUrls: ['../../../css/user_recharge/userRecharge.css'],
    providers: [
        userRechargeService,
        isBindPNService
    ]
})
export class userRechargeComponent {
    public mid: any;
    public money: any;

    constructor(
        private userRechargeService : userRechargeService,
        private isB : isBindPNService
    ){
        this.isB.isId();
        this.isB.isBindPN();
        $.cookie("home","3")
    }

    // 充值
    public recharge(){
        let self : any = this;
        self.mid = $.cookie("id");
        let data: any = {
            member_id: self.mid,
            money: this.money
        };
        self.userRechargeService.userRecharge({
            data: data,
            success: function (result: any) {
                console.log(result);
                if(result.error === 0){
                    alert("充值成功！");
                    self.money = "";
                }else {
                    console.log(result.msg);
                }
            }
        });
    }
}
